package com.tjn.exercise;

/**
 * @author 陶镓妮
 * @version 1.0
 */
public class Exercise01 {
    public static void main(String[] args) {
        //输入的参数应在编辑配置里面输入参数
        try {
            //验证输入的参数是不是两个
            if(args.length != 2){
                throw new ArrayIndexOutOfBoundsException("参数个数不对");
            }

            //把接收到的参数转成整数
            int n1 = Integer.parseInt(args[0]);
            int n2 = Integer.parseInt(args[1]);

            double res = cal(n1,n2);//可能抛出数学异常

            System.out.println("计算结果为：" + res);

        } catch (ArrayIndexOutOfBoundsException e) {
            System.out.println(e.getMessage());
        } catch (NumberFormatException e){
            System.out.println("参数格式不对，需要输出整数");
        } catch (ArithmeticException e){
            System.out.println("出现算数异常");
        }
    }
    public static double cal(int n1,int n2){
        return n1/n2;
    }
}
